/*
 * =====================================================================================
 *
 *       Filename:  chated_mysql_adapter.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2013年05月20日 12时08分20秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Wu Yuxin
 *        Company:  www.Qihoo.net
 *
 * =====================================================================================
 */

#ifndef __IMSERVER_IM_CONTACTSERVICE_CONTACTMYSQL_H__
#define __IMSERVER_IM_CONTACTSERVICE_CONTACTMYSQL_H__

#include <boost/scoped_ptr.hpp>
#include "ImServiceCommon_types.h"
#include "database/simple_db_pool.h"

namespace base { class SimpleConnectionPool; }
namespace imserver {

class ContactMySql {
public:
  ContactMySql(const std::string& database, const std::string& addr, const std::string& user, const std::string& pwd);

  int Insert(const int64_t sender, const int64_t receiver, const time_t timestamp);
  int Delete(const int64_t sender, const int64_t receiver);
  int Select(RecentContactList& contacts, const int64_t uid, const int32_t offset, const int32_t count);

  int UpdateFavorite(const int64_t sender, const int64_t receiver, const time_t timestamp);
  int UpdateRemark(const int64_t sender, const int64_t receiver, const std::string& remark, const time_t timestamp);

private:
  base::SimpleConnectionPool conn_pool_;

};

}

#endif //__IMSERVER_IM_CONTACTSERVICE_CONTACTMYSQL_H__
